﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WaterRevenueMS.Domain.Common.Models;
using System.Web.Mvc;
using System.ComponentModel.DataAnnotations;

namespace WaterRevenueMS.Domain.ViewModels.BaseData.MeterBook
{
    public class MeterBookModel : EntityCommon
    {
        public MeterBookModel()
        {
            Search = new SearchModel();
            DefaultValue = 0;
            AreaItems = new List<SelectListItem>() {
                new SelectListItem { Text = "--- 请选择 ---", Value = "0"}, 
            };
            
        }
        public int  id { get; set; }
        [Display(Name = "表册名称")]
        [Required(ErrorMessage = "请填写表册名称")]
        [StringLength(50, MinimumLength = 2, ErrorMessage = "表册名称{2}～{1}个字符")]
        public string Biao_CMC { get; set; }

        [Display(Name = "表册编码")]
        [Required(ErrorMessage = "请填写表册编码")]
        [StringLength(50, MinimumLength = 2, ErrorMessage = "表册编码{2}~{1}个字节")]
        [Remote("IsUnique_Available", "MeterBook", ErrorMessage = "该编号已经存在")]
        public string Biao_CBH { get; set; }

        public byte DefaultValue { get; set; }

        [Display(Name = "所属区域")]
        public string AreaName { get; set; }
        public List<SelectListItem> AreaItems { get; set; }

        [RegularExpression(@"^\+?[1-9][0-9]*$", ErrorMessage = "请选择所属区域")]
        public int? AreaId { get; set; }

        [Display(Name = "排序序号")]
        [RegularExpression(@"\d+", ErrorMessage = "必须是数字")]
        public int OrderNo { get; set; }

        public SearchModel Search { get; set; }
    }

    public class SearchModel
    {
        public SearchModel()
        {

            AreaItems = new List<SelectListItem>() {
                new SelectListItem { Text = "--- 请选择 ---", Value = "0"}, 
            };
           

        }

        public int id { get; set; }

        [Display(Name = "表册名称")]
        public string Biao_CMC { get; set; }

        [Display(Name = "表册编码")]
        public string Biao_CBH { get; set; }

        [Display(Name = "所属区域")]
        public string AreaName { get; set; }
        public List<SelectListItem> AreaItems { get; set; }
        public int? AreaId { get; set; }

        [Display(Name = "排序序号")]
        public int OrderNo { get; set; }


    }
}
